//
//  DataBaseManager.h
//  YSSmartHome
//
//  Created by Yahaong on 16/8/18.
//  Copyright © 2016年 yahaong. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "FMDB.h"
#import "AirHistoryModel.h"

@class XAITLV;
#define kDataBaseManager [DataBaseManager sharedManager]

typedef void(^CompleteBlock)(NSArray*);
@class OperationModel;
@interface DataBaseManager : NSObject
@property(nonatomic, strong)FMDatabase *database;

///单例
+(instancetype)sharedManager;

/** 队列 */
@property (nonatomic, strong) FMDatabaseQueue *databaseQueue;
/*!
 *  创建表
 */
+ (void)creatTableIfNeed;
- (NSArray *)loadOperationData:(uint32_t)apsn luid:(uint64_t)luid;
- (BOOL)insertOperationModel:(OperationModel *)operation;
- (void)loadAirDataWithApsn:(uint32_t)apsn luid:(uint64_t)luid type:(int)type complete:(CompleteBlock)block;
- (BOOL)insertAirWithApsn:(XAITYPEAPSN)apsn luid:(XAITYPELUID)luid time:(uint32_t)time type:(uint32_t)type value:(float)value;
- (void)storeIMMessagefromApsn:(uint32_t)fromApsn
                      fromLuid:(uint64_t)fromLuid
                        toApsn:(uint32_t)toApsn
                        toLuid:(uint64_t)toLuid
                          type:(uint32_t)type
                        isRead:(uint32_t)isRead
                     timestamp:(uint32_t)timestamp
                          data:(XAITLV *)tlv;
- (void)loadIMMessageWithApsn:(XAITYPEAPSN)apsn luid:(XAITYPELUID)luid complete:(CompleteBlock)complete;
- (void)modifyUnReadMessageWithApsn:(XAITYPEAPSN)apsn luid:(XAITYPELUID)luid;
@end
